from app import db

class NutrientReferenceIntakes(db.Model):
    __tablename__ = 'nutrient_reference_intakes'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    age_group = db.Column(db.String(255), nullable=False)  # 年龄组
    gender = db.Column(db.Integer, nullable=False)  # 性别
    nutrient_name = db.Column(db.String(255), nullable=False)  # 营养素名称
    EAR = db.Column(db.Float)  # 推荐摄入量 EAR
    RNI = db.Column(db.Float)  # 推荐摄入量 RNI
    AMDR_min = db.Column(db.Float)  # AMDR最小值
    AMDR_max = db.Column(db.Float)  # AMDR最大值
    UL = db.Column(db.Float)  # 最大摄入量 UL
    AI = db.Column(db.Float)  # 适宜摄入量 AI

    # 与 lifestyle_adjustments 关联
    lifestyle_adjustments = db.relationship('LifestyleAdjustments', back_populates='nutrient')


    def __repr__(self):
        return f"<NutrientReferenceIntake {self.nutrient_name}, {self.age_group}, {self.gender}>"
